﻿package gui;

import Source.Task;
import java.awt.Dimension;
import java.awt.Toolkit;

public class TaskWindow extends javax.swing.JFrame {
    private Task me;
    public TaskWindow(Task t) {
        me=t;
        initComponents();
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        this.setBounds((int)(screenSize.getWidth()/2)-150, (int)(screenSize.getHeight()/2)-125, 300, 250);
        this.setVisible(true);
        this.Title.setText(me.getTaskTitle());
        if(me.getContext().equalsIgnoreCase("none")){
            this.Context.setVisible(false);
        }else this.Context.setText(me.getContext());
        if(me.getContacts().equalsIgnoreCase("none")){
            this.Contacts.setVisible(false);
        }else this.Contacts.setText(me.getContacts());
        this.Date.setText(me.getDate().toString());
        
    }
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jButtonOk = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        Context = new javax.swing.JTextArea();
        Title = new javax.swing.JTextField();
        jScrollPane2 = new javax.swing.JScrollPane();
        Contacts = new javax.swing.JTextArea();
        Date = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Задача выполнена");

        jButtonOk.setText("Ok");
        jButtonOk.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonOkActionPerformed(evt);
            }
        });

        Context.setEditable(false);
        Context.setColumns(20);
        Context.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        Context.setLineWrap(true);
        Context.setRows(5);
        jScrollPane1.setViewportView(Context);

        Title.setText("jTextField1");

        Contacts.setEditable(false);
        Contacts.setColumns(20);
        Contacts.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        Contacts.setLineWrap(true);
        Contacts.setRows(5);
        jScrollPane2.setViewportView(Contacts);

        Date.setText("jTextField2");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane1)
                    .addComponent(Title)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(Date, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 104, Short.MAX_VALUE)
                        .addComponent(jButtonOk)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(9, 9, 9)
                .addComponent(Title, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonOk)
                    .addComponent(Date, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(63, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>                        

    private void jButtonOkActionPerformed(java.awt.event.ActionEvent evt) {                                          
        setVisible(false);
        dispose();
    }                                         

    // Variables declaration - do not modify                     
    private javax.swing.JTextArea Contacts;
    private javax.swing.JTextArea Context;
    private javax.swing.JTextField Date;
    private javax.swing.JTextField Title;
    private javax.swing.JButton jButtonOk;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    // End of variables declaration                   
}
